// JavaScript Document
$(document).ready(function () {
	var xf_winwidth = $(window).width();
	var xf_winheight = $(window).height();
	$("html").css("fontSize",xf_winwidth/160*7+"px");
	document.body.addEventListener('touchstart', function(){ }); //css active ios 

//index.html页面
	//初始显示投币div or 套餐div
	var index_dv1_span=parseInt($(".index_dv1_span").text());
	if(index_dv1_span>0){
		$(".index_dv2_coin").stop().show();
		$(".index_dv2_combo").stop().hide();
	}else{
		$(".index_dv2_coin").stop().hide();
		$(".index_dv2_combo").stop().show();
	};

	//套餐ul下，小图标是否显示
	var index_dv2_cbspan3=new Array();
	$(".index_dv2_comboul li .index_dv2_cbspan3").stop().hide();
	$(".index_dv2_comboul li").each(function(index){
		index_dv2_cbspan3[index]=parseInt($(".index_dv2_comboul li:eq("+index+") .index_dv2_cbspan3").text());
		if(index_dv2_cbspan3[index]>0){
			$(".index_dv2_comboul li:eq("+index+") .index_dv2_cbspan3").stop().show();
		}
	});

	//购买电子币
	$(".index_dv1_buybtn").on("click", function(){
		$(".index_dv2_coin").stop().slideUp(500);
		$(".index_dv2_combo").stop().show();		
	});
	
	//购买电子币   套餐点击购买
	$(".index_dv2_comboul a").on("click", function(){
		var index_dv1_span=parseInt($(".index_dv1_span").text());
		var index=$(this).closest("li").index();
		var index_dv2_cbspan1=parseInt($(this).find(".index_dv2_cbspan1").text());
		var index_dv2_cbspan2=parseInt($(this).find(".index_dv2_cbspan2").text());
		$(this).addClass("cur");
		if(111){
			$(".index_dv2_comboul a:eq("+index+")").removeClass("cur");
			alert("购买成功", "cur");
			$(".index_dv1_span").text(index_dv1_span+index_dv2_cbspan2);
			$(".index_dv2_coin").stop().show();
			$(".index_dv2_combo").stop().hide();
		}
	});

	//投币按钮
	$(".index_dv2_btn").on("click", function(){
		var index_dv2_numb=parseInt($(".index_dv2_numb").text());
		var index_dv1_span=parseInt($(".index_dv1_span").text());
		alert("投币成功", "cur");	
		$(".index_dv1_span").text(index_dv1_span-index_dv2_numb);
	});
	
	//投币  减号
	$(".index_dv2_left").on("click", function(){
		var index_dv2_numb=parseInt($(".index_dv2_numb").text());
		var index_dv1_span=parseInt($(".index_dv1_span").text());
		if(index_dv2_numb>0){
			index_dv2_numb--;
			$(".index_dv2_numb").text(index_dv2_numb);
		}else{
			index_dv2_numb=0;
			$(".index_dv2_numb").text(index_dv2_numb);
		}	
	});
	
	//投币  加号
	$(".index_dv2_right").on("click", function(){
		var index_dv2_numb=parseInt($(".index_dv2_numb").text());
		var index_dv1_span=parseInt($(".index_dv1_span").text());
		if(index_dv2_numb<index_dv1_span){
			index_dv2_numb++;
			$(".index_dv2_numb").text(index_dv2_numb);
		}else{
			index_dv2_numb=index_dv1_span;
			$(".index_dv2_numb").text(index_dv2_numb);
		}	
	});

//record.html页面
	//上一页
	$(".record_prev").on("click", function(){
		$(".record_page").removeClass("record_page_prev record_page_next");
		$(this).closest("body").find(".record_page").addClass("record_page_prev");
		setTimeout(recordPage, 400);
	});
	//下一页
	$(".record_next").on("click", function(){
		$(".record_page").removeClass("record_page_prev record_page_next");
		$(this).closest("body").find(".record_page").addClass("record_page_next");
		setTimeout(recordPage, 400);
	});
	function recordPage(){
		$(".record_page").removeClass("record_page_prev record_page_next");
	}
	//返回
	$(".record_return").on("click", function(){
		$(this).closest("body").find(".record_page").addClass("record_return");
		setTimeout(recordReturn, 400);
	});
	function recordReturn(){
		$(".record_page").removeClass("record_return");
		window.location.href="index.html";
		//$("body").addClass("index_page");
	}
	

});
$(window).on('resize',function(){
	var xf_winwidth = $(window).width();
	var xf_winheight = $(window).height();
	$("html").css("fontSize",xf_winwidth/160*7+"px");
});
window.onload=function(){
    $(".loading").hide();
};
